#!/bin/zsh

export NETLIB_LOG_INFO=logger
export NETLIB_USE_POLL=poll

work_dir=$PWD
echo "正在编译用户程序 ..."

if [ ! -f "umake.sh" ]; then
	echo "当前目录与该脚本不在同一层"
	exit 1
fi

if [ ! -d "build" ]; then
	echo "创建 build 目录"
	mkdir $work_dir/build
    if [ ! $? -eq 0 ]; then
		echo "创建 build 目录失败"
		exit 1
	fi
else
	rm -rf build/*
fi

echo "进入build目录"
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES ..
make -j2

echo "执行用户程序"
./NetLib
